package game;

public class OutIterator {
	OutNode last;
	OutNode current;

	public OutIterator(OutNode current) {
		this.current = current;
	}

	public boolean hasNext() {
		if (current.next != null && current.next != current) {
			return true;
		}
		return false;
	}

	// because it's a circular list. We don't use hasNext()
	public OutNode getNext() {
		return current.getNext();
	}

	OutNode getCurrent() {
		return current;
	}
	
	/**
	 * goes to the next OutNode
	 * @return
	 */
	public OutNode next() {
		last = current;
		current = current.getNext();
		return current;
	}

	/**
	 * Removes the current node and also link previous with next
	 */
	public void remove() {
		current = current.next;
		last.setNext(current);
	}

	/**
	 * this method is used solely for shuffleOutList();
	 * @return a OutNode with a userName and out of current. (without list logic) 
	 */
	public OutNode copy() {
		OutNode newCopy = null;
//		if (current.out != null) {
//			newCopy = new OutNode(current.userName, current.out);
//		} else {
//			newCopy = new OutNode(current.userName, null);
//		}
		newCopy = new OutNode(current.userName, current.out);
		return newCopy;
	}
}